import { useState } from "react"

// 一个监听滚动条到顶部的hook
export function useWindowScroll () {
  const [y, setY] = useState(0)

  window.addEventListener('scroll', () => {
    const h = document.documentElement.scrollTop
    setY(h)
  })

  return [y]
}